# -*- coding: utf-8 -*-

#    Copyright (C) 2014 by Promotux
#                       di Francesco Meloni snc - http://www.promotux.it/

#    Author: Francesco Meloni  <francesco@promotux.it>

#    This file is part of OdCollect.

#    OdCollect is free software: you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation, either version 2 of the License, or
#    (at your option) any later version.

#    OdCollect is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.

#    You should have received a copy of the GNU General Public License
#    along with OdCollect.  If not, see <http://www.gnu.org/licenses/>.

from sqlalchemy import *
from Environment import *

t_tipo_geo = Table('tipo_geo', meta,
        Column('id', Integer, primary_key=True),
        Column('denominazione', String(100), unique=True),
        Column('denominazione_breve', String(10), unique=True),
        schema=mainSchema,
        extend_existing=True)
t_tipo_geo.create(checkfirst=True)

s= select([t_tipo_geo.c.denominazione_breve]).execute().fetchall()
if (u'Fix',) not in s or s ==[]:
    tg = t_tipo_geo.insert()
    tg.execute(denominazione = "Posizione", denominazione_breve = "Fix")
if (u'Area',) not in s or s ==[]:
    tg.execute(denominazione = "Area", denominazione_breve = "Area")
if (u'Route',) not in s or s ==[]:
    tg.execute(denominazione = "Percorso", denominazione_breve = "Route")
if (u'Alt',) not in s or s ==[]:
    tg.execute(denominazione = "Altitudine", denominazione_breve = "Alt")
